package gcj2011.qual;

import common.AbstractRunner;

public class D  extends AbstractRunner {

	@Override
	public void handleCase(int caseNumber) throws Exception {		
		int n = scanner.nextInt();
		int[] a = new int[n];
		boolean b[] = new boolean[n];
		for (int i=0; i<n; i++) {
			a[i] =  scanner.nextInt();
			b[i] = false;
		}
		
		int res = 0;
		int cur = 0;
		int acc = 0;
		while (cur < n) {			
			if (b[cur]) {
				if (acc>1) {
					res += acc;
				}				
				acc = 0;				
				cur++;
			} else {
				b[cur] = true;
				acc++;
				cur = a[cur]-1;
			}			
		}
		out.write(Integer.toString(res)+".000000\n");
				
	}	
	public static void main(String[] args) throws Exception {
		new D().init(SIZE.large).execute();
//		int n = /*3*/4;		
//		double t = /*10.0/4.0;*/61.0/18.0;
//		double a = /*4.0/6.0;*/ 1.0 - 1.0/n;
//		double res = 0;
//		double factor = 1;
//		for (int i=0; i<1000; i++) {
//			res += (t + i)*a*factor;
//			factor*=1-a;
//		}
//		System.out.println(res+":"+(t-1+1/a));
	}
}
